Fall back to the default positioning when the menuitem is not realized.
authorMatthias Clasen <matthiasc@src.gnome.org>
Thu, 3 Jul 2008 23:33:08 +0000 (23:33 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Thu, 3 Jul 2008 23:33:08 +0000 (23:33 +0000)
        * gtk/gtkmenuitem.c: Fall back to the default positioning when
        the menuitem is not realized. Patch by Björn Lindqvist.

svn path=/trunk/; revision=20754

ChangeLog
gtk/gtkmenuitem.c

index e4bf0f617866a2c7d1f340c8aac85e3e4c63f66e..4279ce600866bd0dd9ae5fe3ec11cef5faad6743 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-07-03  Matthias Clasen  <mclasen@redhat.com>
+
+       Bug 540618 – gtk_menu_shell_select_first prints warning on GtkMenubar
+       constructed using GtkUIManager
+
+       * gtk/gtkmenuitem.c: Fall back to the default positioning when
+       the menuitem is not realized. Patch by Björn Lindqvist.
+
 2008-07-03  Matthias Clasen  <mclasen@redhat.com>
 
        Bug 540612 – mem leak in filechooser
index f343f937713bf8b8889d0e69958087e4efdf38d7..a59b34075283d8ab83d28e5b3a1629bcce942987 100644 (file)
@@ -1141,6 +1141,7 @@ gtk_menu_item_real_popup_submenu (GtkWidget *widget,
   if (GTK_WIDGET_IS_SENSITIVE (menu_item->submenu))
     {
       gboolean take_focus;
+      GtkMenuPositionFunc menu_position_func;
 
       take_focus = gtk_menu_shell_get_take_focus (GTK_MENU_SHELL (widget->parent));
       gtk_menu_shell_set_take_focus (GTK_MENU_SHELL (menu_item->submenu),
@@ -1162,10 +1163,21 @@ gtk_menu_item_real_popup_submenu (GtkWidget *widget,
                              "gtk-menu-exact-popup-time", NULL);
         }
 
+      /* gtk_menu_item_position_menu positions the submenu from the
+       * menuitems position. If the menuitem doesn't have a window,
+       * that doesn't work. In that case we use the default
+       * positioning function instead which places the submenu at the
+       * mouse cursor.
+       */
+      if (widget->window)
+        menu_position_func = gtk_menu_item_position_menu;
+      else
+        menu_position_func = NULL;
+
       gtk_menu_popup (GTK_MENU (menu_item->submenu),
                       widget->parent,
                       widget,
-                      gtk_menu_item_position_menu,
+                      menu_position_func,
                       menu_item,
                       GTK_MENU_SHELL (widget->parent)->button,
                       0);